<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/component/pear/css/pear.css"/>
    <style>
        .centered {
            display: flex;
            flex-direction: row;
            align-items: center;
        }

        .pear-container {
            margin: 15px;
            width: calc(100vw - 30px);
        }

        body {
            font-family: Source Han Sans SC, Source Han Sans SC;
        }

        .toolbarButton button {
            font-size: 16px;
            border: 0px;
            border-radius: 5px 5px 5px 5px;
        }

        .toolbarButton .layui-btn {
            margin-bottom: 0px;
        }

        .layui-table-box button {
            font-size: 14px !important;
            height: 25px;
            line-height: 23px;
        }

        #moreTools a {
            color: #1890FF;
            margin-left: 20px;
        }

        .dataIcon-1 {
            width: 296px;
            height: 154px;
            background-image: url('/img/SystemSettings/恢复平台所有数据.png');
            background-size: cover;
            background-position: center;
        }

        .dataIcon-2 {
            width: 296px;
            height: 154px;
            background-image: url('/img/SystemSettings/重置数据.png');
            background-size: cover;
            background-position: center;
        }

        .dataText {
            width: 296px;
            height: 69px;
            background: #F8F8F8;
            border-radius: 0px 0px 8px 8px;
        }

        .dataText .title {
            font-size: 16px;
            color: #363F4A;
            line-height: 14px;
            padding: 15px 20px;
        }

        .dataText .content {
            font-size: 14px;
            color: #AFBBCB;
            line-height: 14px;
            margin-left: 20px;
        }
    </style>
</head>
<body class="pear-container">
<div class="layui-row layui-col-space15">
    <div class="layui-col-xs12 layui-col-md12">
        <div class="layui-card">
            <div class="layui-card-body" style="min-height: calc(100vh - 50px)">
                <div class="layui-row centered" style="margin-left: 12px;margin-top: 6px;">
                    <div style="width: 4px;height: 20px;background: #2176FF;"></div>
                    <div style="margin-left: 10px;height: 27px;font-weight: 500;font-size: 18px;color: #000000;line-height: 27px;">
                        数据管理
                    </div>
                </div>
                <div class="layui-row"
                     style="display: flex;flex-direction: column;margin-top: 5px;margin-left: 12px;margin-right: 12px;">
                    <img src="/img/console/网格.png" alt="" style="max-width: 100%;">
                </div>
                <div style="margin-top:31px;margin-left: 41px;display: flex;flex-direction: row;">
                    <div>
                        <div class="dataIcon-1"></div>
                        <div class="dataText">
                            <div class="title">备份平台所有数据</div>
                            <div class="content">一键备份导出平台所有数据文件</div>
                        </div>
                    </div>
                    <div style="margin-left: 50px;">
                        <div class="dataIcon-2"></div>
                        <div class="dataText">
                            <div class="title">重置平台设备数据</div>
                            <div class="content">一键重置平台设备数据</div>
                        </div>
                    </div>
                </div>
                <div style="margin-top: 10px;">
                    <table id="user-table" lay-filter="user-table"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/component/layui/layui.js"></script>
<script src="/component/pear/pear.js"></script>
<script>
    layui.use(['table', 'form', 'jquery', 'common'], function () {
        let table = layui.table;
        let form = layui.form;
        let $ = layui.jquery;
        let common = layui.common;

        let cols = [
            [
                {title: '账号', field: 'user_name', align: 'center', width: 100},
                {title: '姓名', field: 'nick_name', align: 'center'},
                {title: '部门', field: 'dept_name', align: 'center'},
                {title: '邮箱', field: 'email', align: 'center'},
                {title: '启用', field: 'status', align: 'center', templet: '#user-status'},
                {title: '创建时间', field: 'create_time', align: 'center', templet: '#user-createTime', sort: true},
                {title: '操作', toolbar: '#user-bar', align: 'center', width: 220}
            ]
        ]

        tableIns = table.render({
            elem: '#user-table',
            url: '/my/user/list',
            page: true,
            cols: cols,
            skin: 'line',
            id: 'user-table',
            // height: 'full-173',
            //解决页码的问题
            done: function (res) {
                // 获得当前页码
                var brforeCurr = tableIns.config.page.curr;
                // 获得当前页的记录数
                var dataLength = table.cache['user-table'].length;
                var count = res.count; // 获得总记录数
                //如果当前页的记录数为0并且总记录数不为0
                if (dataLength == 0 && count != 0) {
                    // 刷新表格到上一页
                    table.reload("user-table", {
                        page: {
                            curr: brforeCurr - 1
                        }
                    });
                }
            }
        });
    });

</script>
</body>
</html>